Public Class ARTraceSwitch
	Inherits TraceSwitch

	<System.Diagnostics.DebuggerStepThrough()> Public Sub New(ByVal displayName As String, ByVal description As String)
		MyBase.New(displayName, description)
	End Sub

	<System.Diagnostics.DebuggerStepThrough()> Public Sub WError(ByVal msg As String)
		Trace.WriteLineIf(Me.TraceError, msg, Me.DisplayName)
	End Sub

	<System.Diagnostics.DebuggerStepThrough()> Public Sub WWarning(ByVal msg As String)
		Trace.WriteLineIf(Me.TraceWarning, msg, Me.DisplayName)
	End Sub


    <System.Diagnostics.DebuggerStepThrough()> _
    Public Sub WInfo(ByVal msg As String)

        Trace.WriteLineIf(Me.TraceInfo, msg, Me.DisplayName)
    End Sub

    Public Sub WInfo(ByVal format As String, ByVal ParamArray args As Object())
        Me.WInfo(String.Format(format, args))
    End Sub


    <System.Diagnostics.DebuggerStepThrough()> Public Sub WVerbose(ByVal msg As String)
        Trace.WriteLineIf(Me.TraceVerbose, msg, Me.DisplayName)
    End Sub


End Class

Public Class ReadableTextWriterTraceListener
    Inherits TraceListener

    Private _fname As String
    Private tw As IO.TextWriter
    Public Sub New(ByVal fileName As String)
        _fname = fileName
    End Sub



    Public Overloads Overrides Sub Write(ByVal message As String)
        If tw Is Nothing Then
            tw = New IO.StreamWriter(_fname, True)
        End If

        If MyBase.NeedIndent Then
            Me.WriteIndent()
        End If
        tw.Write(message)
        tw.Close()
        tw = Nothing
    End Sub

    Public Overloads Overrides Sub WriteLine(ByVal message As String)
        If MyBase.NeedIndent Then
            Me.WriteIndent()
        End If
        Write(message + Environment.NewLine)
        MyBase.NeedIndent = True
    End Sub
End Class